package util

import (
	"toy-car/pkg/setting"

	"github.com/gin-gonic/gin"
	"github.com/unknwon/com"
)

func GetPageAndSize(c *gin.Context) (page, pageSize int) {
	page, err := com.StrTo(c.Query("current")).Int()
	if err != nil || page < 1 {
		page = 1
	}

	pageSize, err = com.StrTo(c.Query("pageSize")).Int()
	if err != nil || pageSize < 1 {
		pageSize = setting.PageSize
	}
	return
}
